<template>
  <div class="user">

     <!--添加产品-->
     <div class="common-level-rail">
      <el-button size="small" icon="el-icon-plus" type="primary" @click="addClick">添加</el-button>
    </div>

    <!--内容-->
    <div class="product-content">
      <div class="table-wrap">
        <el-table size="small" :data="tableData" border style="width: 100%" v-loading="loading">
          <el-table-column prop="team" label="队伍"></el-table-column>
        
          <el-table-column prop="national_flag_l" label="国旗（左)">
            <template slot-scope="scope">
              <img v-img-url="scope.row.national_flag_l" width="30px" height="30px"/>
            </template>
          </el-table-column>
          <el-table-column prop="national_flag_r" label="国旗（右)">
            <template slot-scope="scope">
              <img v-img-url="scope.row.national_flag_r" width="30px" height="30px"/>
            </template>
          </el-table-column>
       
          <el-table-column prop="start_time_text" label="竞猜开始时间"></el-table-column>
          <el-table-column prop="end_time_text" label="竞猜结束时间"></el-table-column>
          <el-table-column prop="status_text" label="状态"></el-table-column>
          <el-table-column prop="score_text" label="最终比分"></el-table-column>
          <el-table-column fixed="right" label="操作">
            <template slot-scope="scope">
              <el-button @click="editClick(scope.row)" type="text" size="small">编辑
              </el-button>
              <el-button @click="deleteClick(scope.row)" type="text" size="small">删除 </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>

      <!--分页-->
      <div class="pagination">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          background
          :current-page="curPage"
          :page-size="pageSize"
          layout="total, prev, pager, next, jumper"
          :total="totalDataNumber"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import europeanApi from '@/api/european.js';

export default {
  components: {},

  data() {
    return {
      searchForm: {
      
      },
      /*是否加载完成*/
      loading: true,
      /*列表数据*/
      tableData: [],
      /*一页多少条*/
      pageSize: 20,
      /*一共多少条数据*/
      totalDataNumber: 0,
      /*当前是第几页*/
      curPage: 1,
      /*横向表单数据模型*/
      formInline: {
     
      },
    
    };
  },
  created() {

    /*获取列表*/
    this.getTableList();
  },
  methods: {
    /*选择第几页*/
    handleCurrentChange(val) {
      let self = this;
      self.curPage = val;
      self.loading = true;
      self.getTableList();
    },

    /*每页多少条*/
    handleSizeChange(val) {
      this.curPage = 1;
      this.pageSize = val;
      this.getTableList();
    },

    /*获取列表*/
    getTableList() {
      let self = this;
      let Params = this.searchForm;
      Params.page = self.curPage;
      Params.list_rows = self.pageSize;
      europeanApi.europeanmatchlist(Params, true)
        .then(data => {
          self.loading = false;
          self.tableData = data.data.list.data;
          self.totalDataNumber = data.data.list.total;
        })
        .catch(error => {
        });
    },

    /*打开添加*/
    addClick() {
      this.$router.push('/plus/european/european/addeuropeanmatch');
    },

     /*打开编辑*/
     editClick(row) {
      let self = this;
      let params = row.european_match_id;
      this.$router.push({
        path: '/plus/european/european/editeuropeanmatch',
        // name: 'mallList',
        query: {
          european_match_id: row.european_match_id
        }
      });
    },


       /*删除*/
      deleteClick(row) {
      console.log('数据',row)
      let self = this;
      self
        .$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
        .then(() => {
          europeanApi.deletematch(
            {
              european_match_id: row.european_match_id
            },
            true
          )
            .then(data => {
              self.$message({
                message: '删除成功',
                type: 'success'
              });
              self.getTableList();
            })
            .catch(error => {
            });
        })
        .catch(() => {
        });
    }
  }
};
</script>

<style></style>
